-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add doorbell #30
base: dev
Are you sure you want to change the base?
Add doorbell #30
Conversation
gateway/Automation/Automation.hpp
Outdated
@@ -82,6 +82,10 @@ void kitchenOff() { | |||
setOutput(KITCHEN_TABLE_ID, Relay::OFF); | |||
} | |||
|
|||
void doorbellclick() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let’s use camelCase naming with callback for callback functions, ie:
‘doorbellClickCallback’
gateway/Automation/Automation.hpp
Outdated
@@ -82,6 +82,10 @@ void kitchenOff() { | |||
setOutput(KITCHEN_TABLE_ID, Relay::OFF); | |||
} | |||
|
|||
void doorbellclick() { | |||
dzwonek=1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For enumerated values Enum can be proposed based on CPP code style guidelines:
‘’’
enum DoorBellState
{
DISABLED = 0,
ENABLED = 1,
SWITCHED = 2,
}
‘’’
See ‘Relay’ enum.
gateway/gateway.ino
Outdated
@@ -15,6 +15,8 @@ | |||
#define MY_BAUD_RATE 115200 | |||
#endif | |||
|
|||
uint8_t dzwonek = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer English language for variable names: ‘doorbellState‘
gateway/Automation/Automation.hpp
Outdated
@@ -120,4 +124,6 @@ void setupButtons() { | |||
workshop.attachClick(clickCallback, WORKSHOP_ID); | |||
|
|||
corridor.attachClick(clickCallback, CORRIDOR_ID); | |||
|
|||
doorbell.attachPressStart(doorbellclick); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use camelCase for callback as mentioned above.
gateway/gateway.ino
Outdated
@@ -71,6 +73,21 @@ void loop() { | |||
kitchenTable.tick(); | |||
workshop.tick(); | |||
corridor.tick(); | |||
doorbell.tick(); | |||
|
|||
switch (dzwonek) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Switch can be encapsulated in function (ie: ‘updateDoorbellState’) to avoid too long implementation of ‘loop’ and additionally it will automatically explain it’s purpose.
- As the current code doesn’t have any validation in any other places, it’s good practice to add implementation of default behaviour, even if it will never fall into it and there will be only ‘break’ instruction.
Changes tested and working ok.